package cn.sc.allinpay.allfavour.module.printer;

import android.text.TextUtils;

import com.landicorp.android.eptapi.device.Printer;
import com.landicorp.android.eptapi.utils.QrCode;

/**
 * 发券打印
 * author：pany
 * on 2017/11/3 11:48
 */
public class DistCouponPrinter extends BasePrinter {

    public DistCouponPrinter(PrintData data) {
        super(data);
    }

    @Override
    protected void printBody(Printer printer, PrintData data) throws Exception {
        printer.setFormat(FormatStyle.createNormalFont());
        printer.println("凭 证 号:" + data.getCouponSeqNum());
        printer.println("交易时间:" + data.getTime());
        printer.println("交易类型:" + data.getTransName());
        printer.println("发券名称:" + data.getCouponName());
        printer.println("发券类型:电子券");
        printer.println("数量: x" + data.getCouponUseNum());
        if(!TextUtils.isEmpty(data.getCouponUrl())) {
            printer.println("            领券码");
            QrCode qrCode = new QrCode(data.getCouponUrl(), QrCode.ECLEVEL_Q);
            printer.printQrCode(Printer.Alignment.CENTER, qrCode, 300);
        }else {
            printer.println("");
        }
    }

    @Override
    protected void printFooter(Printer printer, PrintData data) throws Exception {
        printer.feedLine(4);
    }
}
